// This example shows how change the update rate of an existing subscription. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Threading; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.DataAccess.OperationModel; namespace DocExamples.DataAccess._EasyDAClient { partial class ChangeItemSubscription { public static void Main1() { // Instantiate the client object. using (var client = new EasyDAClient()) { client.ItemChanged += client_ItemChanged; Console.WriteLine("Subscribing..."); int handle = client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Changing subscription..."); client.ChangeItemSubscription(handle, new DAGroupParameters(100)); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); Console.WriteLine("Unsubscribing..."); client.UnsubscribeAllItems(); Console.WriteLine("Waiting for 10 seconds..."); Thread.Sleep(10 * 1000); } } // Item changed event handler static void client_ItemChanged(object sender, EasyDAItemChangedEventArgs e) { if (e.Succeeded) Console.WriteLine(e.Vtq); else Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief); } } }
' This example shows how change the update rate of an existing subscription. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports System.Threading Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.DataAccess.OperationModel Namespace DataAccess._EasyDAClient Partial Friend Class ChangeItemSubscription Public Shared Sub Main1() Using client = New EasyDAClient() AddHandler client.ItemChanged, AddressOf client_ItemChanged Console.WriteLine("Subscribing...") Dim handle As Integer = client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000) Console.WriteLine("Waiting for 10 seconds...") Thread.Sleep(10 * 1000) Console.WriteLine("Changing subscription...") client.ChangeItemSubscription(handle, New DAGroupParameters(100)) Console.WriteLine("Waiting for 10 seconds...") Thread.Sleep(10 * 1000) Console.WriteLine("Unsubscribing...") client.UnsubscribeAllItems() Console.WriteLine("Waiting for 10 seconds...") Thread.Sleep(10 * 1000) End Using End Sub ' Item changed event handler Private Shared Sub client_ItemChanged(ByVal sender As Object, ByVal e As EasyDAItemChangedEventArgs) If e.Succeeded Then Console.WriteLine(e.Vtq) Else Console.WriteLine("*** Failure: {0}", e.ErrorMessageBrief) End If End Sub End Class End Namespace
Rem This example shows how change the update rate of an existing subscription. Rem Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript . Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own Rem a commercial license in order to use Online Forums, and we reply to every post. Option Explicit Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient") WScript.ConnectObject Client, "Client_" WScript.Echo "Subscribing..." Dim handle: handle = Client.SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000) WScript.Echo "Waiting for 10 seconds..." WScript.Sleep 10*1000 WScript.Echo "Changing subscription..." Client.ChangeItemSubscription handle, 100 WScript.Echo "Waiting for 10 seconds..." WScript.Sleep 10*1000 WScript.Echo "Unsubscribing..." Client.UnsubscribeAllItems WScript.Echo "Waiting for 10 seconds..." WScript.Sleep 10*1000 WScript.DisconnectObject Client Set Client = Nothing Sub Client_ItemChanged(Sender, e) If Not (e.Succeeded) Then WScript.Echo "*** Failure: " & e.ErrorMessageBrief Exit Sub End If WScript.Echo e.Vtq End Sub
# This example shows how change the update rate of an existing subscription. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.EasyOpc.DataAccess import * # Item changed event handler def itemChanged(sender, e): if e.Succeeded: print(e.Vtq) else: print('*** Failure: ', e.ErrorMessageBrief, sep='') # Instantiate the client object. client = EasyDAClient() client.ItemChanged += itemChanged print('Subscribing item...') handle = IEasyDAClientExtension.SubscribeItem(client, '', 'OPCLabs.KitServer.2', 'Simulation.Random', 1000) print('Processing item change notifications for 10 seconds...') time.sleep(10) print('Changing item subscription...') IEasyDAClientExtension.ChangeItemSubscription(client, handle, DAGroupParameters(100)) print('Processing item change notifications for 10 seconds...') time.sleep(10) print('Unsubscribing item...') IEasyDAClientExtension.UnsubscribeItem(client, handle) print('Waiting for 10 seconds...') time.sleep(10) client.ItemChanged -= itemChanged print('Finished.')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.